package com.example.ssm.dao;

import com.example.ssm.entity.Book;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

public interface BookRepository  extends JpaRepository<Book,Long>{

    //复杂查询-根据最小id查询书本信息
    @Query(value = "select * from book where id=(select min(id) from book )",
    nativeQuery = true)
    Book getMinIdBook();

//    @Query(value = "select b.id,b.name,b.author,b.price,c.title,c.content from book b left join chapter c on b.id = c.book_id where b.id=4" ,nativeQuery = true)
//    List<BookChapter> getBook();
}
